{literal}
<script type="text/javascript">
    $(document).ready(function(){
    	var cpf = '{/literal}{$cliente->vhr_cpf}{literal}';
        $("#form_cliente").validate({
            rules: {
            	cpf: { required: true, verificaCPF: true },
                nome: { required: true },
                nascimento: { required: true, dateBR: true}
            },
            messages: {
            	cpf: {required:"Obrigatorio"},
                nome: "Obrigatorio",
                nascimento: { required: "Obrigatorio" }
            },
            submitHandler: function(form) {
				jqAjaxForm(form, "div_mensagem");
			}
			
        });
        $('#cpf').mask("999.999.999-99");
        $('#nascimento').mask("99/99/9999");
        $('#rgorgaouf').mask("aaa/aa");
        $('#nascimento').datepick({showOn: 'both'});
        
        if (cpf!="")
        {
        	{/literal}
        	{foreach name=lista from=$contatos item=contato key=k}
        		adicionarLinhaContato("num_contatos", "div_cliente_contato", false, {$k+1}, '{$contato->tipocontato_id}', '{$contato->vhr_valor}', '{$_site.url}');
        	{/foreach}
        	{foreach name=lista2 from=$enderecos item=endereco key=k}
        		adicionarLinhaEndereco("num_enderecos", "div_cliente_endereco", false, {$k+1}, '{$endereco->tipoendereco_id}', '{$_site.url}', '{$endereco->vhr_endereco}', '{$endereco->vhr_bairro}', '{$endereco->cidade_id}', '{$endereco->uf_id}', '{$endereco->vhr_cep}');
        	{/foreach}
        	{literal}
        }
        
        $("#btn_adicionar").click(function() {
        	adicionarLinhaContato("num_contatos", "div_cliente_contato", true, 0, 0, "", '{/literal}{$_site.url}{literal}');
        });
        
        $("#btn_adicionar_end").click(function() {
        	adicionarLinhaEndereco("num_enderecos", "div_cliente_endereco", true, 0, 0, '{/literal}{$_site.url}{literal}',"","","","","");
        });
    }); //fecha $(
    
</script>
{/literal}
    <form id="form_cliente" name="form_cliente" method="post" action="{$_site.url}{$acao}">
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="mvTituloFundo">
				  <tr>
					<td>
					{if $cliente->pessoa_id > 0}Editar{else}Novo{/if} Cliente
					<input type="hidden" name="cod" value="{$cliente->cliente_id}"/>
			        <input type="hidden" name="template_secundario" id="template_secundario" value="{$templateSecundario}"/>
			        <input type="hidden" name="esconde_form" id="esconde_form" value="{$escondeForm}"/>
					</td>
				  </tr>
				</table>
    			<table width="100%" border="0" cellspacing="0" cellpadding="0">                
                <tr>
                  <td class="contForm">
                  
                  <table width="100%" border="0" cellspacing="3" cellpadding="0">
                      <tr>
                        <td width="30%" valign="top" class="fundoTituloForm">CPF:</td>
                        <td class="bordaFormResp" colspan="3"><input type="text" class="formulario" name="cpf" id="cpf" size="14" maxlength="14" value="{$cliente->vhr_cpf}"/></td>
                      </tr>
                      <tr>
                        <td valign="top" class="fundoTituloForm">Nome:</td>
                        <td class="bordaFormResp" colspan="3"><input type="text" class="formulario tamanhoForm" name="nome" id="nome" size="50" maxlength="50" value="{$cliente->vhr_nome}"/></td>
                      </tr>
                      <tr>
                        <td valign="top" class="fundoTituloForm">Nascimento:</td>
                        <td class="bordaFormResp" colspan="3"><input type="text" class="formulario" name="nascimento" id="nascimento" size="11" maxlength="10" value="{$cliente->dte_nascimento}"/></td>
                      </tr>
                      <tr>
                        <td valign="top" class="fundoTituloForm">RG:</td>
                        <td class="bordaFormResp"><input type="text" class="formulario" name="rg" id="rg" size="14" maxlength="14" value="{$cliente->vhr_rg}"/></td>
                        <td valign="top" class="fundoTituloForm">Órgão expedidor/UF:</td>
                        <td class="bordaFormResp"><input type="text" class="formulario" name="rgorgaouf" id="rgorgaouf" size="6" maxlength="6" value="{$cliente->vhr_rgorgaouf}"/></td>
                      </tr>
                      <tr>
                        <td class="bordaFormResp" colspan="4">
	                        <fieldset>
					        <legend><b>CONTATOS</b></legend>
					        <table width="100%" border="0" cellspacing="0" cellpadding="0">                
			                  <tr>
			                  	 <td class="contForm">
			                  	 	<table width="100%" border="0" cellspacing="3" cellpadding="0" id="div_cliente_contato">
			                  	 		
			                  	 	</table>
			                  	 </td>
			                  </tr>
		                    </table>
					        <input type="hidden" name="num_contatos" id="num_contatos" value="{$totalContatos}"/>
					        <input type="button" value="adicionar" id="btn_adicionar" name="btn_adicionar" class="botao"/><br/>
					        </fieldset>
						</td>
                      </tr>
                      <tr>
                        <td class="bordaFormResp" colspan="4">
	                        <fieldset>
					        <legend><b>ENDEREÇOS</b></legend>
					        <table width="100%" border="0" cellspacing="0" cellpadding="0">
			                  <tr>
			                  	 <td class="contForm" id="div_cliente_endereco">
			                  	 	
			                  	 </td>
			                  </tr>
		                    </table>
					        <input type="hidden" name="num_enderecos" id="num_enderecos" value="{$totalEnderecos}"/>
					        <input type="button" value="adicionar" id="btn_adicionar_end" name="btn_adicionar_end" class="botao"/>
					        </fieldset>
						</td>
                      </tr>
                  </table>
                  
                  </td>
                </tr>
        <tr>
                  <td class="paddingTop15 paddingBottom15" align="center"><!-- === Botões ( Salvar e Limpar ) === -->
                      <span class="paddingRight15">
                      	<input type="submit" value="Salvar" class="botao">
                      </span>
                    <span class="paddingRight15">
                    <input name="limpar" type="reset" id="Limpar" value="Limpar" class="botao" />
                    </span>
                    <input type="button" value="Cancelar" onclick="cancelar(); return false;" class="botao">
                      <!-- Final === Botões ( Salvar e Limpar ) === -->                      </td>
                </tr>
              </table>
    </form>
